<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Event/classes/PhpFox_ComponentEventGuests.class.php, $Author:  $ */



/** Component for showing and adding comments to events
 * @version $Id: PhpFox_ComponentEventGuests.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.event
 *   
 */
class PhpFox_Mod_Event_ComponentEventGuests extends BaseComponent
{
    function process()
    {
        $oEventInviteItem = $this->_oModule->getItem('EventInvite');
        /* @var $oEventInviteItem PhpFox_Mod_Event_ItemEventInvite */
        $oSecurityService = &App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        $oReq = &App::getRequest();
        $oUrl = &App::getUrl();
        $oTpl = $this->_oModule->getTemplate();
        App::loadClass('Pager');

        $oSecurityService->checkPerm('events', array('read_only', 'full'));
        $oSecurityService->checkAccess('events');
        $iEventId = $oReq->getInt('id');
        if (!$iEventId)
        {
            App::gotoUrl('public.event.main');
        }
        $aCond = array();
        $aCond['event_id'] = '= '.$iEventId;
        $aCond['invite']   = '= 1';
        $iPage = $oReq->get('page1', 1);
        $iPageSize = App::getParam('public.event_guests_count');
        $sSort = 'time DESC';
        list($aItems, $iCnt) = $oEventInviteItem->getList($aCond, $iPage, $iPageSize, $sSort);
        $oPager = &new Pager($iCnt, $iPage, $iPageSize);
        $oPager->sUrlKey = 'page1';
        $iFrom = $oPager->getOffset($iPage, $iPageSize);
        $iTo = (($iFrom + $iPageSize) > $iCnt) ? $iCnt : ($iFrom + $iPageSize);

        $oTpl->assign(array(
        	'iFrom'      => ($iCnt) ? ($iFrom + 1) : 0,
        	'iTo'        => $iTo,
        	'iCnt'       => $iCnt,
        	'aItems'     => $aItems,
        	'aPaging'    => ($iCnt) ? $oPager->getInfo($oUrl) : '',
        	'sUImageUrl' => App::getParam('user.pic.url'),
        ));
        return $oTpl->fetch('EventGuests.html');
    }
}
?>